package com.ss.android.article.base.feature.f;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.feature.f.a.f;
import com.ss.android.article.base.feature.f.b.b;
import com.ss.android.article.base.feature.video.MediaHelper;
import com.ss.android.article.browser.R;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.newmedia.BaseApplication;

import org.json.JSONException;
import org.json.JSONObject;

public final class aa extends com.ss.android.article.base.feature.f.a.a implements com.ss.android.article.base.feature.f.bb.b$a {
    public aa(Context arg2) {
        super(arg2);
        this.p = new a$a(this);
    }

    static long a(aa arg2) {
        return arg2.b;
    }

    static JSONObject b(aa arg1) {
        return arg1.d;
    }

    static long c(aa arg2) {
        return arg2.b;
    }

    static JSONObject d(aa arg1) {
        return arg1.d;
    }

    static long e(aa arg2) {
        return arg2.b;
    }

    static JSONObject f(aa arg1) {
        return arg1.d;
    }

    static boolean g(aa arg1) {
        return arg1.a;
    }

    static b h(aa arg1) {
        return arg1.i;
    }

    static b i(aa arg1) {
        return arg1.i;
    }

    static b j(aa arg1) {
        return arg1.i;
    }

    static JSONObject k(aa arg1) {
        return arg1.d;
    }

    static JSONObject l(aa arg1) {
        return arg1.d;
    }

    static long m(aa arg2) {
        return arg2.b;
    }

    static JSONObject n(aa arg1) {
        return arg1.d;
    }

    static b o(aa arg1) {
        return arg1.i;
    }

    static b p(aa arg1) {
        return arg1.i;
    }

    static b q(aa arg1) {
        return arg1.i;
    }

    static JSONObject r(aa arg1) {
        return arg1.d;
    }

    static JSONObject s(aa arg1) {
        return arg1.d;
    }

    static long t(aa arg2) {
        return arg2.b;
    }

    static JSONObject u(aa arg1) {
        return arg1.d;
    }

    static long v(aa arg2) {
        return arg2.b;
    }

    public final void a(int arg3, int arg4) {
        super.a(arg3, arg4);
        UIUtils.setVisibility(((com.ss.android.article.base.feature.f.bb) this.h).a, 0);
        ((com.ss.android.article.base.feature.f.bb) this.h).a(true);
    }

    public final com.ss.android.article.base.feature.f.c.a a(Context arg2, b arg3) {
        return new com.ss.android.article.base.feature.f.bb(arg2, ((bb.b$a) this), arg3);
    }

    public final com.ss.android.m.c.a.a a() {
        return new e();
    }

    public final void b() {
        super.b();
        UIUtils.setVisibility(((com.ss.android.article.base.feature.f.bb) this.h).b, 8);
    }

    public final void c() {
        if (this.h != null && !this.m()) {
            boolean v2 = this.i.d();
            com.ss.android.article.base.feature.f.c.a v0 = this.h;
            int v1 = v2 ? R.drawable.play_movebar_textpage : R.drawable.media_pause_icon_selector;
            ((com.ss.android.article.base.feature.f.bb) v0).a(v1);
            if (v2) {
                ((com.ss.android.article.base.feature.f.bb) this.h).b();
                super.b(false);
                return;
            }

            ((com.ss.android.article.base.feature.f.bb) this.h).a(false);
            ((com.ss.android.article.base.feature.f.bb) this.h).a();
            this.a(false);
        }
    }

    public final void d() {
        super.d();
        View v1 = ((f) this).h.c();
        if (v1.getParent() != null && ((v1.getParent() instanceof ViewGroup))) {
            ((ViewGroup) v1.getParent()).removeView(v1);
        }
    }

    public final class a$a extends com.ss.android.m.b.a {
        private final aa b;

        public a$a(aa arg1) {
            this.b = arg1;

        }

        public final void a() {
            super.a();
            if (this.b()) {
                try {
                    long v0_1 = aa.o(this.b).b();
                    long v2 = aa.p(this.b).a();
                    aa.r(this.b).putOpt("duration", Long.valueOf(aa.q(this.b).b()));
                    aa.s(this.b).putOpt("percent", Integer.valueOf(MediaHelper.timeToPercent(v0_1, v2)));
                } catch (JSONException v0) {
                }

                MobClickCombiner.onEvent(BaseApplication.getApplication(), "embeded_ad", "detail_over", aa.t(this.b), 0, aa.u(this.b));
            }
        }

        public final void a(boolean arg10) {
            long v6 = 0;
            super.a(arg10);
            if (this.b()) {
                if (arg10) {
                    MobClickCombiner.onEvent(BaseApplication.getApplication(), "embeded_ad", "detail_play", aa.a(this.b), v6, aa.b(this.b));
                } else {
                    MobClickCombiner.onEvent(BaseApplication.getApplication(), "embeded_ad", "detail_continue", aa.c(this.b), v6, aa.d(this.b));
                }
            }
        }

        private boolean b() {
            boolean v0 = aa.v(this.b) > 0 ? true : false;
            return v0;
        }

        public final void b(boolean arg10) {
            super.b(arg10);
            if ((this.b()) && !arg10) {
                MobClickCombiner.onEvent(BaseApplication.getApplication(), "embeded_ad", "detail_pause", aa.e(this.b), 0, aa.f(this.b));
            }
        }

        public final void c(boolean arg10) {
            super.c(arg10);
            if ((this.b()) && !aa.g(this.b) && (arg10)) {
                try {
                    long v0_1 = aa.h(this.b).b();
                    long v2 = aa.i(this.b).a();
                    aa.k(this.b).putOpt("duration", Long.valueOf(aa.j(this.b).b()));
                    aa.l(this.b).putOpt("percent", Integer.valueOf(MediaHelper.timeToPercent(v0_1, v2)));
                } catch (JSONException v0) {
                }

                MobClickCombiner.onEvent(BaseApplication.getApplication(), "embeded_ad", "detail_break", aa.m(this.b), 0, aa.n(this.b));
            }
        }
    }
}

